package com.longsichao.lscframe.tools;

import android.util.Base64;

public class Base {
    private Base() {
    }

    /**
     * base64 编码
     */
    public static String getFromBASE64StringEncode(byte[] input) {
        if (input.length < 0) {
            return null;
        }
        try {
            byte[] b = Base64.encode(input, Base64.DEFAULT);
            return new String(b);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * base64 解码
     */
    public static byte[] getFromBASE64Byte(String s) {
        if (s == null) {
            return new byte[0];
        }
        try {
            return Base64.decode(s.getBytes(), Base64.DEFAULT);
        } catch (Exception e) {
            return new byte[0];
        }
    }
}
